/**
 * Created by Administrator on 2017/1/14.
 */
tableSort($('.helper-list'));
function tableSort(obj) {
    var actionColumnIndex = $('.helper-name th').length;
    if (!actionColumnIndex || actionColumnIndex < 1) {
        return;
    }
    obj.dataTable({
        "aaSorting": [[1, "desc"]],
        "bStateSave": false,
        "aoColumnDefs": [
            {
                "orderable": false, "aTargets": [0, actionColumnIndex - 1]
            }
        ],
        "aLengthMenu": [[7], [7]],
        "sPaginationType": "full_numbers",
        "sDom": '<"top">rt<"bottom">p<"clear">'
//            "sDom": '<"top"fli>rt<"bottom">p<"clear">'
    });
}
tableSort($('#text_helper'));
function tableSort1(obj) {
    var actionColumnIndex = $('#helpername th').length;
    if (!actionColumnIndex || actionColumnIndex < 1) {
        return;
    }
    obj.dataTable({
        "aaSorting": [[1, "desc"]],
        "bStateSave": false,
        "aoColumnDefs": [
            {
                "orderable": false, "aTargets": [0, actionColumnIndex - 1]
            }
        ],
        "aLengthMenu": [[7], [7]],
        "sPaginationType": "full_numbers",
        "sDom": '<"top">rt<"bottom">p<"clear">'
//            "sDom": '<"top"fli>rt<"bottom">p<"clear">'
    });
}
//日历切换
$(function(){
    function initTableCheckbox() {
        var $thr = $('.team_ckd thead tr');
        var $checkAllTh = $('<th><input type="checkbox" id="checkAll" name="checkAll" />全选</th>');
        /*将全选/反选复选框添加到表头最前，即增加一列*/
        $thr.prepend($checkAllTh);
        /*“全选/反选”复选框*/
        var $checkAll = $thr.find('input');
        $checkAll.click(function(event){
            /*将所有行的选中状态设成全选框的选中状态*/
            $tbr.find('input').prop('checked',$(this).prop('checked'));
            /*并调整所有选中行的CSS样式*/
            if ($(this).prop('checked')) {
                $tbr.find('input').parent().parent().addClass('warning');
            } else{
                $tbr.find('input').parent().parent().removeClass('warning');
            }
            /*阻止向上冒泡，以防再次触发点击操作*/
            event.stopPropagation();
        });
        /*点击全选框所在单元格时也触发全选框的点击操作*/
        $checkAllTh.click(function(){
            $(this).find('input').click();
        });
        var $tbr = $('.team_ckd tbody tr');
        var $checkItemTd = $('<td><input type="checkbox" name="checkItem" /></td>');
        /*每一行都在最前面插入一个选中复选框的单元格*/
        $tbr.prepend($checkItemTd);
        /*点击每一行的选中复选框时*/
        $tbr.find('input').click(function(event){
            /*调整选中行的CSS样式*/
            $(this).parent().parent().toggleClass('warning');
            /*如果已经被选中行的行数等于表格的数据行数，将全选框设为选中状态，否则设为未选中状态*/
            $checkAll.prop('checked',$tbr.find('input:checked').length == $tbr.length ? true : false);
            /*阻止向上冒泡，以防再次触发点击操作*/
            event.stopPropagation();
        });
        /*点击每一行时也触发该行的选中操作*/
        $tbr.click(function(){
            $(this).find('input').click();
        });
    }
    initTableCheckbox();
});
//个人信息与修改个人信息切换
$(function(){
    $(".revisePre").click(function(){
            var display=$("#information>li:first-child").css("dispaly");
            if(display=="none"){
                $("#information>li:first-child").css("display","block");
                $("#information>li:first-child").siblings().css("display","none");
            }else{
                $("#information>li:first-child").css("display","none");
                $("#information>li:first-child").siblings().css("display","block");
            }
        }
    );
});
$(function () {
    $.ms_DatePicker({
        YearSelector: ".sel_year",
        MonthSelector: ".sel_month",
        DaySelector: ".sel_day"
    });
    $.ms_DatePicker();
});
$(function () {
    $('#myId3').jalendar();
});
$(document).ready(function () {
    $('body').on('hidden', '.modal', function () {
        $(this).removeData('modal');
    });
});
$(function(){
    $("#pre-list>li").click(function(){
        var index=$(this).index();
        $("#myTab>li").eq(index).addClass("active").siblings().removeClass("active");
    });
});
function check(id) {
    var frameSrc = "{:U('Doctor/helper')}"+"?id="+id;
    $("#NoPermissioniframe").attr("src", frameSrc);
    $('#NoPermissionModal').modal({ show: true, backdrop: 'static' });
}